package mains;

import java.util.Collection;
import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.TypedQuery;

import app.Merchant;

public class Main4TypedQuery {

    private static final String PERSISTENCE_UNIT_NAME = "CashM";
    private static EntityManagerFactory factory;

    public static void main(String[] args) {
	factory = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME);
	EntityManager em = factory.createEntityManager();
	

	TypedQuery<Merchant> query = em.createQuery("SELECT m FROM Merchant m",
		Merchant.class);
	List<Merchant> listM = null;

	try {
	    listM = query.getResultList();
	} finally {
	    em.close();
	}
	if (listM != null) {
	    for (Merchant m : listM) {
		System.out.println(m.toString());
	    }
	}

    }

}
